package siar.web.managedbeans;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

import siar.webservice.PratoBean;
import siar.webservice.ServicosSIARSoap;

public class PratosMB {
	private List<PratoBean> pratos;
	
	public List<PratoBean> getPratos() {
		getPratosWS();
		return pratos;
	}

	public void getPratosWS(){
		ServicosSIARSoap ws;
		try {
			ws = (ServicosSIARSoap) Naming.lookup("rmi://localhost/servicosSIAR");
			PratoBean[] p;
			this.pratos = new ArrayList<PratoBean>();
			p = ws.pratoListar();
			for(int i=0; i<p.length; i++){
				this.pratos.add(p[i]);
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		}
	}

}
